<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
%><!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>登录页面 -药品生产变更管理平台</title>
<link rel="icon" href="<%=path%>/images/favicon.ico" type="image/ico">
<meta name="author" content="guowenjie">
<link href="<%=path%>/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">
<link href="<%=path%>/css/style.min.css" rel="stylesheet">
<link rel="stylesheet" href="<%=path%>/js/jconfirm/jquery-confirm.min.css">

<style>
.lyear-wrapper {
    position: relative;
}
.lyear-login {
    display: flex !important;
    min-height: 100vh;
    align-items: center !important;
    justify-content: center !important;
}
.login-center {
    background: #fff;
    min-width: 38.25rem;
    padding: 2.14286em 3.57143em;
    border-radius: 5px;
    margin: 2.85714em 0;
}
.login-header {
    margin-bottom: 1.5rem !important;
}
.login-center .has-feedback.feedback-left .form-control {
    padding-left: 38px;
    padding-right: 12px;
}
.login-center .has-feedback.feedback-left .form-control-feedback {
    left: 0;
    right: auto;
    width: 38px;
    height: 38px;
    line-height: 38px;
    z-index: 4;
    color: #dcdcdc;
}
.login-center .has-feedback.feedback-left.row .form-control-feedback {
    left: 15px;
}
</style>
</head>
  
<body>
<div id="divlog">
<div class="row lyear-wrapper">
  <div class="lyear-login" >
    <div class="login-center" >
      <div class="login-header text-center">
       <h2 align="center" style="color:LightSteelBlue ">药品生产变更管理平台</h2>
      </div>
      <form action="#!" method="post">
        <div class="form-group has-feedback feedback-left">
          <input type="text" placeholder="请输入您的用户名" class="form-control" name="username" id="username" />
          <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <input type="password" placeholder="请输入密码" class="form-control" id="password" name="password" />
          <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
        </div>
        
        <div class="form-group  feedback-right "  style="float:right">
          <a  onclick="showzc();">账号申请</a>
        </div>
        
        <div class="form-group">
          <button class="btn btn-block btn-primary" type="button" id="login-button">立即登录</button>
        </div>
      </form>
      <hr>
      <footer class="col-sm-12 text-center">
        <p class="m-b-0">Copyright © 2021 <a href="https://www.huahaipharm.com">华海药业</a>. All right reserved</p>
      </footer>
    </div>
    
    
    
  </div>
  
</div>
  </div>
  <div id="divzc" style="display:none"  >
 <div class="container-fluid p-t-15" >
  
  <div class="row"  >
  <div class="col-lg-2" ></div>
    <div class="col-lg-8" >
      <div class="card" >
        <div class="card-body">
          
          <form id="yhxx" enctype="multipart/form-data"  class="row">
            <div class="form-group col-md-12">
              <label for="name">姓名</label>
              <input type="text" class="form-control" id="name" name="zhsq.name"  />
            </div>
            <div class="form-group col-md-12">
              <label for="card">身份证号码</label>
              <input type="text" class="form-control" id="card" name="zhsq.card"  />
            </div>
            <div class="form-group col-md-12">
              <label for="companyname">公司名称</label>
             <input type="text" class="form-control" id="companyname" name="zhsq.companyname"  />
            </div>
            <div class="form-group col-md-12">
              <label for="phone">手机号码</label>
             <input type="text" class="form-control" id="phone" name="zhsq.phone"  />
            </div>
            <div class="form-group col-md-12">
              <label for="email">电子邮箱</label>
             <input type="text" class="form-control" id="email" name="zhsq.email"  />
            </div>
           <div class="form-group col-md-12">
              <label>上传附件|<a href="<%=path%>/xzfj">申请表下载</a>(注：表格填写完毕后扫描pdf文件上传)</label>
              <input type="file"  id="file" accept=".pdf" name="zhsq.file">
             
            </div>
            <div class="form-group col-md-12">
              <button type="button" class="btn btn-primary" onclick="savexx()">确 定</button>
              <button type="button" class="btn btn-default" onclick="showlog()">返 回</button>
            </div>
          </form>
 
        </div>
      </div>
    </div>
     <div class="col-lg-2" ></div>
  </div>
  
</div>
    </div>
    

<script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap.min.js"></script>
<script type="text/javascript" src='<%=path%>/js/main/login.js'></script>
<script type="text/javascript" src="<%=path%>/js/main/form.validate.js"></script>
<script src="<%=path%>/js/jconfirm/jquery-confirm.min.js"></script>
<script type="text/javascript">
var url="<%=path%>";

function IdentityCodeValid(code) {
    var city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
    var tip = "";
    var pass= true;

    if(!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)){
       // tip = "身份证号格式错误";
        pass = false;
    }

   else if(!city[code.substr(0,2)]){
        //tip = "地址编码错误";
        pass = false;
    }
    else{
        //18位身份证需要验证最后一位校验位
        if(code.length == 18){
            code = code.split('');
            //∑(ai×Wi)(mod 11)
            //加权因子
            var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
            //校验位
            var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
            var sum = 0;
            var ai = 0;
            var wi = 0;
            for (var i = 0; i < 17; i++)
            {
                ai = code[i];
                wi = factor[i];
                sum += ai * wi;
            }
            var last = parity[sum % 11];
            if(parity[sum % 11] != code[17]){
                tip = "校验位错误";
                pass =false;
            }
        }
    }
    if(!pass) return false;
    return true;
}
		


function savexx(){
	let name = $("#name").val();
	let card = $("#card").val();
	let companyname = $("#companyname").val();
	let phone = $("#phone").val();
	let email = $("#email").val();
	let file = $("#file").val();
	
	let message = "";
	
	if(name==""){
		message = message +"请填写姓名;";	
	}
	
	
	if(phone==""){
		message = message +"请填写电话;";	
	}else{
		var phonereg = /^[0-9\-]*$/;
		if(!phonereg.test(phone)){
			message = message +"请填写正确的电话号码;";		
		}
	}
	
	if(email==""){
		message = message +"请填写邮箱;";	
	}else{
		var emailreg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
		if(!emailreg.test(email)){
			message = message +"请填写正确的邮箱;";		
		}
	}
	 
	if(card==""){
		message = message +"请填写身份证;";	
	}else{
		
		if(IdentityCodeValid(card)==false){
			message = message +"请填写正确的身份证;";		
		}
		
	}
	
	
	if(companyname==""){
		message = message +"请填写公司名称;";	
	}
	
	if(file.length == 0){
		message = message +"请上传附件;";	
	}
	
	if(message!=""){
		$.alert(message);
		return false;
	}else{
		
		
		
		$.ajax({
		    url: '<%=path%>/savesqxx',
		    type: 'POST',
		    cache: false,
		    data: new FormData($('#yhxx')[0]),
		    processData: false,
		    contentType: false
		}).done(function(res) {
			showlog();
    		name = $("#name").val("");
    		 card = $("#card").val("");
    		 companyname = $("#companyname").val("");
    		 phone = $("#phone").val("");
    		 email = $("#email").val("");
    		 file = $("#file").val("");
    		 $.alert("申请已提交成功");
     		
    		return true;
		}).fail(function(res) {});
		
	}
	
	
	
	
	
}


function showzc(){
	
	document.getElementById("divlog").style.display ="none";
	document.getElementById("divzc").style.display ="block";
}

function showlog(){
	name = $("#name").val("");
	 card = $("#card").val("");
	 companyname = $("#companyname").val("");
	 phone = $("#phone").val("");
	 email = $("#email").val("");
	 file = $("#file").val("");
	
	document.getElementById("divlog").style.display ="block";
	document.getElementById("divzc").style.display ="none";
}
</script> 
</body>
</html>